﻿#pragma once

#include "../MonsterObject.h"
#include "../../MirDatabase/MonsterInfo.h"
#include "../../../Shared/Enums.h"
#include "../PlayerObject.h"
#include "../MapObject.h"
#include "../../../Shared/Packet.h"
#include <vector>
#include <any>

using namespace Server::MirDatabase;
using namespace Server::MirEnvir;
namespace S = ServerPackets;

namespace Server::MirObjects::Monsters
{
    class TreeQueen : public MonsterObject
    {
    protected:
        bool getCanMove() const override;
        bool getCanRegen() const override;

    private:
        const int _rootSpreadMin = 5;
        const int _rootSpreadMax = 15;
        const int _rootCount = 5;
        long long _rootSpawnTime = 0;

        const int _groundrootSpread = 5;
        long long _groundRootSpawnTime = 0;

        const int _nearMultiplier = 4;
        bool _notNear = true;

    protected:
        TreeQueen(MonsterInfo *info);

        bool InAttackRange() override;

    public:
        void Turn(MirDirection dir) override;

        bool Walk(MirDirection dir) override;

        int Attacked(MonsterObject *attacker, int damage, DefenceType type = DefenceType::ACAgility) override;

        int Attacked(PlayerObject *attacker, int damage, DefenceType type = DefenceType::ACAgility, bool damageWeapon = true) override;

        void ApplyPoison(Poison *p, MapObject *Caster = nullptr, bool NoResist = false, bool ignoreDefence = true) override;

    protected:
        void Attack() override;

        void CompleteAttack(std::vector<std::any> &data) override;

    private:
        void SpawnRoots();

        void SpawnMassRoots();

        void SpawnGroundRoots();

    public:
        Packet *GetInfo() override;

        void Spawned() override;

    protected:
        void ProcessTarget() override;
    };
}
